{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {
        "content": "### ... or watch set up video [13 min]\n[![Youtube Thumbnail](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/Youtube%20AI%20Agent%20Blur.png)](https://youtu.be/6RmLZS8Yl4E)\n",
        "height": 239.5888196628349,
        "width": 330.5152611046425,
        "color": 7
      },
      "id": "1ee7b7a3-a752-4262-9e39-39402f5683b7",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -1152
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "![5min Logo](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/banner.png)\n## AI Agent To Chat With Youtube\n**Made by [Mark Shcherbakov](https://www.linkedin.com/in/marklowcoding/) from community [5minAI](https://www.skool.com/5minai)**\n\nNavigating the content generation and optimization process can be complex, especially without significant audience insight. This workflow automates insights extraction from YouTube videos and comments, empowering users to create more engaging and relevant content effectively.\n\nThe workflow integrates various APIs to gather insights from YouTube videos, enabling automated commentary analysis, video transcription, and thumbnail evaluation. The main functionalities include:\n- Extracting user preferences from comments.\n- Transcribing video content for enhanced understanding.\n- Analyzing thumbnails via AI for maximum viewer engagement insights.\n\n",
        "height": 497.1532689930921,
        "width": 636.2128494576581,
        "color": 7
      },
      "id": "cf1fc601-606f-4d48-aa58-92b522cc98a2",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -1680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "### Set up steps\n\n1. **API Setup**:\n   - Create a [Google Cloud](https://console.cloud.google.com/apis/dashboard) project and enable the YouTube Data API.\n   - Generate an API key for [Apify](https://www.apify.com?fpr=ujogj).\n   - Generate API key for [OpenAI](https://platform.openai.com)\n   - Create all credentials in N8N - OpenAI, Apify, Google Cloud.\n\n2. **YouTube Creator and Video Selection**:\n   - Start by defining a request to identify top creators based on their video views.\n   - Capture the YouTube video IDs for further analysis of comments and other video metrics.\n\n3. **Comment Analysis**:\n   - Gather comments associated with the selected videos and analyze them for user insights.\n   - Implement pagination to handle the maximum comment retrieval limits in API requests.\n\n4. **Video Transcription**:\n   - Request transcriptions for videos of interest, ensuring to manage potential costs associated with longer video processing.\n   - Utilize the insights from transcriptions to formulate content plans.\n\n5. **Thumbnail Analysis**:\n   - Evaluate your video thumbnails by submitting the URL through the OpenAI API to gain insights into their effectiveness.\n\n6. **Data Management**:\n   - Incorporate a database agent to organize video data and metrics, allowing efficient record management and future content planning.",
        "height": 545.9087885077763,
        "width": 280.2462120317618,
        "color": 7
      },
      "id": "f6d6bb28-bda2-465e-9c00-5eb041c2ec0d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -1152
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "86e4ead2-4e1a-4714-8f49-1c90f291b7eb",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        176,
        -1088
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "name": "get_channel_details",
        "description": "Get channel_id, title and description by handle/username.\nChannel_id is required to find videos and details about this channel.\nIf Youtube link to channel provided - parse handle from there or return channel_id. (e.g. https://www.youtube.com/@example_handle - example_handle)\n\n\nExample Input:\nexample_handle\n\nExample Output:\nid:UCOgz_YflAsYnGbdvzXuKNCA\ntitle:Daniel Simmons\ndescription:Digital Diary 🤎\\n\\n\\nWeekly videos around fashion...",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "=get_channel_details"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"handle\": {\n      \"type\": \"string\",\n      \"description\": \"Handle/username of channel\"\n    }},\n  \"required\": [\"handle\"]\n}"
      },
      "id": "cdb55005-aa4a-4562-86c8-700b46b58a7c",
      "name": "get_channel_details",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        528,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "get_video_description",
        "description": "Fetch video details - the full description, title, and publish date of a video using its video_id.\n\nExample input:\nvideo_id:dQw4w9WgXcQ\n\nExample Output:\ntitle:Never Gonna Give You Up\ndescription: \"The official video for “Never Gonna Give You Up” by Rick Astley.\nduration:4 min\nviewCount:154\nlikeCount:6\nthumbnails: urls",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "video_details"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"video_id\": {\n      \"type\": \"string\",\n      \"description\": \"The ID of the video to fetch details for\"\n    }\n  },\n  \"required\": [\"video_id\"]\n}"
      },
      "id": "cea22ac4-f347-46cd-aa63-61fdda162f69",
      "name": "get_video_description",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        656,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "get_list_of_videos",
        "description": "Retrieve a list of videos from a channel using channel_id. Supports sorting by date, relevance, or view count.\n\nExample Input:\nchannel_id\": \"UCxxxxxxxxxxxxxxxx\"\nnumber_of_videos\": 5\norder: \"date\"\npublishedAfter: \"timestamp\"\n\nExample Output:\nvideo_id:abc123\ntitle:Latest Video\nshort cut description:Latest Video\npublished_at:2023-12-05T10:00:00Z",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "videos"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"channel_id\": {\n      \"type\": \"string\",\n      \"description\": \"The ID of the channel to fetch videos from\"\n    },\n    \"number_of_videos\": {\n      \"type\": \"integer\",\n      \"description\": \"The maximum number of videos to retrieve (max 50)\"\n    },\n    \"order\": {\n      \"type\": \"string\",\n      \"enum\": [\"date\", \"relevance\", \"viewCount\"],\n      \"description\": \"Order in which to fetch videos\"\n    },\n    \"publishedAfter\": {\n      \"type\": \"string\",\n      \"description\": \"Timestamp for filtering like 2023-11-03T15:28:05Z.\"\n    }\n  },\n  \"required\": [\"channel_id\", \"number_of_videos\", \"order\"]\n}"
      },
      "id": "2a87baf9-7bcd-41c9-97a4-c4240dd932cd",
      "name": "get_list_of_videos",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        768,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "get_list_of_comments",
        "description": "Retrieve a list of comments from a video using video_id.\n\nInput:\n  \"video_id\": \"dQw4w9WgXcQ\"\n\nOutput:\n    \"author\": \"John Doe\",\n    \"comment\": \"This is an amazing video!\",\n    \"published_at\": \"2023-12-04T12:00:00Z\"",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "comments"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"video_id\": {\n      \"type\": \"string\",\n      \"description\": \"The ID of the video to fetch comments from\"\n    }\n  },\n  \"required\": [\"video_id\"]\n}"
      },
      "id": "e4ec5ab7-4e73-4951-b2de-43e14ad75cf9",
      "name": "get_list_of_comments",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        896,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "search",
        "description": "Search for videos or channels using a query. Supports filtering by type (video or channel) and sorting (date, viewCount, relevance). Use | for OR and - to exclude terms in the query.\n\nInput:\ntype: video or channel\nquery: search query\nsorting: date, viewCount, relevance\npublishedAfter: timestamp\n\nOutput:\n- id, title, short cut description, and published_at.",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "search"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"type\": {\n      \"type\": \"string\",\n      \"enum\": [\"video\", \"channel\"],\n      \"description\": \"Type of results to retrieve: video or channel\"\n    },\n    \"query\": {\n      \"type\": \"string\",\n      \"description\": \"Search query. Supports | for OR and - to exclude terms\"\n    },\n    \"sorting\": {\n      \"type\": \"string\",\n      \"enum\": [\"date\", \"viewCount\", \"relevance\"],\n      \"description\": \"Sorting criteria for search results\"\n    },\n    \"publishedAfter\": {\n      \"type\": \"string\",\n      \"description\": \"Timestamp for filtering like 2023-11-03T15:28:05Z\"\n    }\n  },\n  \"required\": [\"type\", \"query\", \"sorting\"]\n}"
      },
      "id": "775bd4b4-845f-4382-866d-32ae1acb3941",
      "name": "search",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1008,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "analyze_thumbnail",
        "description": "Analyze a thumbnail image based on a given prompt. The prompt can be customized for specific analysis needs, such as design critique, color scheme evaluation, or content assessment.\nUse link of maxRes thumbnail. \n\nInput:\n- url: URL of the thumbnail image.\n- prompt: Customizable instruction for the analysis.\n\nOutput:\n- Results of the analysis based on the given prompt.",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "analyze_thumbnail"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"url\": {\n      \"type\": \"string\",\n      \"description\": \"URL of the thumbnail image to analyze\"\n    },\n    \"prompt\": {\n      \"type\": \"string\",\n      \"description\": \"Customizable instruction to guide the image analysis\"\n    }\n  },\n  \"required\": [\"url\", \"prompt\"]\n}"
      },
      "id": "b159b8a9-e480-4661-8f2b-e598eb2ce44a",
      "name": "analyze_thumbnail",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1136,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "name": "video_transcription",
        "description": "Transcribe a video and retrieve its text transcription. Useful for analyzing video content or repurposing it for other formats.\n\nInput:\n- video_url: URL of the video to transcribe.\n\nOutput:\n- The text transcription of the video.",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "FgknOUpOBkpY85NX",
          "cachedResultName": "Youtube parser - tools"
        },
        "fields": {
          "values": [
            {
              "name": "command",
              "stringValue": "video_transcription"
            }
          ]
        },
        "specifyInputSchema": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"video_url\": {\n      \"type\": \"string\",\n      \"description\": \"URL of the video to transcribe\"\n    }\n  },\n  \"required\": [\"video_url\"]\n}"
      },
      "id": "ce8f834a-bc7a-4efd-b2a7-715a7394f3d9",
      "name": "video_transcription",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1248,
        -1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('When chat message received').item.json.sessionId }}"
      },
      "id": "82bd30f9-3444-469e-b774-57427b0a01d4",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        336,
        -1088
      ],
      "typeVersion": 1.3
    },
    {
      "parameters": {
        "agent": "openAiFunctionsAgent",
        "promptType": "define",
        "text": "={{ $('When chat message received').item.json.chatInput }}",
        "options": {
          "systemMessage": "You are Youtube assistant. \nYou need to process user's requests and run relevant tools for that. \n\nPlan and execute in right order runs of tools to get data for user's request.\n\nIMPORTANT Search query and list of videos for channel tools returns all videos including shorts - use Get Video description tool to identify shorts (less than minute) and filter them out if needed.\n\nFeel free to ask questions before do actions - especially if you noticed some inconcistency in user requests that might be error/misspelling. "
        }
      },
      "id": "8c1c9646-47f5-4a75-ba8b-431e709387b1",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        384,
        -1360
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "bdd6c7b9-c18d-441d-950c-5884b5a426bb",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        96,
        -1312
      ],
      "webhookId": "6e95bc27-99a6-417c-8bf7-2831d7f7a4be",
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "content": "## Scenario 1: AI agent",
        "height": 588.1344471094899,
        "width": 1430.34590072234
      },
      "id": "b6c41e56-451f-4813-abfb-2df5393fae3c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -1408
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/youtube/v3/commentThreads",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "id,snippet,replies"
            },
            {
              "name": "videoId",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.video_id }}"
            },
            {
              "name": "maxResults",
              "value": "100"
            }
          ]
        },
        "options": {}
      },
      "id": "ffc5064f-4fad-4448-8f61-f592f029ce6c",
      "name": "Get Comments",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        -320
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {},
      "id": "e82c93e9-08ef-44e2-a791-14d83b72ecf0",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        80,
        -320
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/youtube/v3/channels",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "forHandle",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.handle }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a7d392e4-3d89-4327-955e-c8828331c220",
      "name": "Get Channel Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        -640
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/youtube/v3/videos",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet,contentDetails,statistics"
            },
            {
              "name": "id",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.video_id }}"
            }
          ]
        },
        "options": {}
      },
      "id": "6e58e05e-a399-4e60-af5c-41a55bd57993",
      "name": "Get Video Description",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        -480
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "469d89ba-23fc-482a-b4ae-ce5d3bc13579",
              "name": "response",
              "type": "string",
              "value": "={{ JSON.stringify(`  Comments:  ${$json.items.map(item => {   const topLevelComment = `${item.snippet.topLevelComment.snippet.authorDisplayName}: ${item.snippet.topLevelComment.snippet.textOriginal}`;   const replies = item.replies?.comments.map(reply =>      `${reply.snippet.authorDisplayName}: ${reply.snippet.textOriginal}`   ).join('\\n') || '';   return [topLevelComment, replies].filter(Boolean).join('\\n'); }).join('\\n\\n')}    `) }}"
            }
          ]
        },
        "options": {}
      },
      "id": "5396c381-fd9f-40a0-b1ad-23e3bc084a7e",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        848,
        -320
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/youtube/v3/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "q",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.query }}"
            },
            {
              "name": "order",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.order }}"
            },
            {
              "name": "type",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.type }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.number_of_videos }}"
            },
            {
              "name": "publishedAfter",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.publishedAfter }}"
            }
          ]
        },
        "options": {}
      },
      "id": "93239a6a-c157-419f-8784-48d06f5feb86",
      "name": "Run Query",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        -160
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "url": "=https://www.googleapis.com/youtube/v3/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "channelId",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.channel_id }}"
            },
            {
              "name": "order",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.order }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.number_of_videos }}"
            },
            {
              "name": "type",
              "value": "video"
            },
            {
              "name": "publishedAfter",
              "value": "={{ $('Execute Workflow Trigger').item.json.query.publishedAfter }}"
            }
          ]
        },
        "options": {}
      },
      "id": "6cef5429-7f8d-4a30-a2b3-a4ef31f35c4f",
      "name": "Get Videos by Channel",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        0
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cfdbe2f5-921e-496d-87bd-9c57fdc22a7a",
              "name": "response",
              "type": "object",
              "value": "={{$json}}"
            }
          ]
        },
        "options": {}
      },
      "id": "7e9a002d-bc26-49f1-88b1-13b98ff3c8f3",
      "name": "Response",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        -320
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "get_channel_details"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "get_channel_details"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "26a3ffe8-c8a6-4564-8d18-5494a8059372",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "video_details"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "video_details"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0f51cc26-2e42-42e1-a5c2-cb1d2e384962",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "comments"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "comments"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "51031140-5ceb-48aa-9f33-d314131a9653",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "search"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "search"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f160bf0a-423f-448d-ab80-50a0b6a177ca",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "videos"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "videos"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "29542ac4-7b9d-413f-aabb-a1cdabed2fa7",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "analyze_thumbnail"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "analyze_thumbnail"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35fc39b8-6cf1-4ea6-9609-4a195c5526f8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Execute Workflow Trigger').item.json.command }}",
                    "rightValue": "video_transcription"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "video_transcription"
            }
          ]
        },
        "options": {}
      },
      "id": "5029f9e0-212f-4f31-b0ba-0cb9a098f395",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        256,
        -336
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.apify.com/v2/acts/dB9f4B02ocpTICIEY/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"startUrls\": [\n    \"{{ $('Execute Workflow Trigger').item.json.query.video_url }}\"\n  ]\n}",
        "options": {}
      },
      "id": "715b00f3-61b9-4e94-8661-99ba9a38ad5c",
      "name": "Get Video Transcription",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        688,
        320
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "text": "={{ $('Execute Workflow Trigger').item.json.query.prompt }}",
        "imageUrls": "={{ $('Execute Workflow Trigger').item.json.query.url }}",
        "options": {}
      },
      "id": "3d99d26a-d3b9-49ed-984b-daf3eceb6edf",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        688,
        160
      ],
      "typeVersion": 1.7
    },
    {
      "parameters": {
        "content": "## Scenario 2: Agent tools",
        "height": 1313.2689194736308,
        "width": 1427.3810326521016
      },
      "id": "349a69bb-69c3-4d3d-97ae-b80857d2ae76",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -768
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "### Replace credentials",
        "height": 80,
        "width": 266.7375650720483,
        "color": 4
      },
      "id": "6f31ac22-39f4-47c7-96cd-f8aba0af54ec",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -960
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "### Replace credentials in all nodes - Apify, OpenAI, Google",
        "height": 80,
        "width": 266.7375650720483,
        "color": 4
      },
      "id": "2b1a5e4c-4b13-4f45-98a3-b3d9d33bd10a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -736
      ],
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Execute Workflow Trigger": [
      {
        "json": {
          "query": {
            "type": "video",
            "query": "Web scraping data with n8n and Puppeteer",
            "sorting": "relevance"
          },
          "command": "search"
        }
      }
    ]
  },
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get Channel Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Video Description",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Comments",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Run Query",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Videos by Channel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Video Transcription",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "search": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Run Query": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Comments": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "analyze_thumbnail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "get_list_of_videos": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Channel Details": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_channel_details": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "video_transcription": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "get_list_of_comments": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Description": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Videos by Channel": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_video_description": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Transcription": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "862d505b-9780-4c8a-8b04-1583f488351c",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "108ca395ced197c6477117d33be04fdbb054b19068f57471dcf11fcb19567da0"
  },
  "id": "ullZK5zc0t-Q5w-2B_z0n",
  "tags": []
}